# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'

class FeedmeExtension < Radiant::Extension
  version "1.0"
  description "Reuse any feed you wish."
  url "http://code.google.com/p/feed-me"
  
  ENV["tmp_feeds_path"] = File.join(RAILS_ROOT, "tmp", "feeds")
  
  define_routes do |map|
    map.resources :feeds, :path_prefix => "admin", :controller => "admin/feeds"
  end
  
  def activate
    admin.tabs.add "Feeds", "/admin/feeds", :after => "Layouts", :visibility => [:all]
    Page.send :include, FeedmeTags
    PaginatedFeed
    
    Dir.mkdir(ENV["tmp_feeds_path"]) unless File.exist? ENV["tmp_feeds_path"]
  end
  
  def deactivate
    admin.tabs.remove "Feeds"
  end
  
end